/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.webapp.service;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

/**
 *
 * @author Tonytran
 */
public class FileDemo {
    
   public static void main(String args) throws IOException {
        // Here we are assuming that folder "D:\Gautam\testing\" exists and
        // user has privilege to create file in testing folder
        File file = new File("C:/first.txt");
 
        boolean b = false;
 
        /*
         * exists() method tests whether the file or directory denoted by this
         * abstract pathname exists or not accordingly it will return TRUE /
         * FALSE.
         */
 
        if (!file.exists()) {
 
            /*
             * createNewFile() method is used to creates a new, empty file
             * mentioned by given abstract pathname if and only if a file with
             * this name does not exist in given abstract pathname.
             */
            b = file.createNewFile();
        }
 
        if (b)
            System.out.println("Empty File successfully created");
        else
            System.out.println("Failed to create File");
 
    }
}
